﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using STATCONNECTORSRVLib;

namespace Common
{
    public class RHelper
    {
        private static StatConnector sc;
        static RHelper()
        {
            sc = new STATCONNECTORSRVLib.StatConnectorClass();
            sc.Init("R");
        }
        public static void DrawPlot(double[] data)
        {
            StatConnector sc1 = new STATCONNECTORSRVLib.StatConnectorClass();
            sc1.Init("R");
            sc1.SetSymbol("x", data);
            sc1.Evaluate("plot(x)");
        }

        public static void DrawPlot(double[] datax, double[] datay)
        {
            StatConnector sc1 = new STATCONNECTORSRVLib.StatConnectorClass();
            sc1.Init("R");
            sc1.SetSymbol("x", datax);
            sc1.SetSymbol("y", datay);
            sc1.Evaluate("plot(x,y)");
        }

        public static void DrawDynamicPlot(double[] data)
        {
            sc.SetSymbol("x", data);
            sc.Evaluate("plot(x,type='b')");
        }
    }
}
